package com.store.controller;

import com.store.domain.R;
import com.store.domain.entity.Address;
import com.store.domain.entity.User;
import com.store.service.AddressService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author yu
 * @date 2024/6/26
 */
@RestController
@RequestMapping("address")
public class AddressController {
    @Resource
    private AddressService addressService;
    @GetMapping()
    public R getMyAllAddress(){
        return addressService.getMyAllAddress();
    }
    @PostMapping
    public R addAddress(@RequestBody Address address){
        return addressService.addAddress(address);
    }
    @DeleteMapping()
    public R deleteAddress(Integer id){
        return addressService.deleteAddress(id);
    }
    @PutMapping
    public R updateAddress(@RequestBody Address address){
        return addressService.updateAddress(address);
    }
    @PutMapping("cancelDefault/{id}")
    public R cancelDefault(@PathVariable Integer id){
        return addressService.cancelDefault(id);
    }
    @PutMapping("setDefault/{id}")
    public R setDefault(@PathVariable Integer id){
        return addressService.setDefault(id);
    }
}
